const fs = require("fs");

exports.getMime = function(extname){
    switch (extname) {
        case ".html":
            return "text/html";
            break;
        case ".css":
            return "text/css";
            break;
        case ".js":
            return "text/javascript";
            break;
        default:
            return "text/html";
            break;
    }
}

exports.getFileMime = function(extname){
    return new Promise((resolve,reject)=>{
        fs.readFile("./data/mime.json",(err,data)=>{
            if(err){
                console.log(err);
                reject(err);
                return;
            }
            let mimeObj = JSON.parse(data.toString());
            // console.log(mimeObj[extname]);
            resolve(mimeObj[extname]);
        }) 
    })
}